<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../lib/vue-2.6.7.js"></script>
    <style type="text/css">
        [v-cloak]{
            display: none
        }
    </style>
</head>
<body>
    <div id="app" v-cloak>
        {{message|trimToUpper}}
    </div>
    <script>
        const vm = new Vue({
            //定义顾虑器去除首尾空字符串，并把首字母转为大写
            filters:{
                trimToUpper:function(value){
                    if(!value) return ''
                    if(typeof value=='string')
                    return value.trim().charAt(0).toLocaleUpperCase()+value.slice(3)
                }
            },
            el:"#app",
            data:{
                message:"  hello vue"
            }
        })
    </script>
</body>
</html>